#ifndef _QY_UTIL_H
#define _QY_UTIL_H

#include <cstdio>
#include <string>

namespace qy
{

#define delete_null(p)	do{	\
							if(p)	delete (p);	\
							p = NULL;	\
						}while(0)

void fatal(const char *format, ...);

enum LogLevel
{
	DEBUG_LEVEL = 0,
	SYS_LEVEL,
	WANING_LEVEL,
	ERROR_LEVEL
};

#define __MODULE__ NULL
#define log_debug(...) log(DEBUG_LEVEL, __MODULE__, __VA_ARGS__)
#define log_sys(...) log(SYS_LEVEL, __MODULE__, __VA_ARGS__)
#define log_warning(...) log(WARNING_LEVEL, __MODULE__, __VA_ARGS__)
#define log_error(...) log(ERROR_LEVEL, __MODULE__, __VA_ARGS__)

void log(LogLevel level, const char *module, const char *format, ...); 

std::string& operator+(std::string &str, int i);

}

#endif
